package com.ftg.learn.pubsub;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author 布衣
 */
public class Product {

    public static final String exName = "msg";
    public static void main(String[] args) {


        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        factory.setPort(5672);
        factory.setVirtualHost("/");
        factory.setUsername("admin");
        factory.setPassword("admin");

        try(
                Connection connection = factory.newConnection();
        ) {
            Channel channel = connection.createChannel();

            channel.exchangeDeclare(exName, BuiltinExchangeType.FANOUT);

            channel.basicPublish(exName, "", null, "hello world".getBytes());

        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

}
